#include "stdafx.h"
#include "rock.h"
#include "solitaire.h"

rock::rock(const QPoint &coord)
    : QGraphicsObject()
    //, sol_(sol)
    , coord_(coord)
{
    setFlag(ItemIsMovable, true);
    setFlag(ItemSendsScenePositionChanges, true);
}

rock::~rock()
{
                                                        
}

QRectF rock::boundingRect() const
{
    return QRectF(-solitaire::ROCK_RADIUS, -solitaire::ROCK_RADIUS, 2 * solitaire::ROCK_RADIUS, 2 * solitaire::ROCK_RADIUS);
}

void rock::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
{
    painter->setBrush(Qt::black);
    painter->drawEllipse(-solitaire::ROCK_RADIUS, -solitaire::ROCK_RADIUS, 2 * solitaire::ROCK_RADIUS, 2 * solitaire::ROCK_RADIUS);
}

void rock::cancel_turn()
{
    //setPos(sol_->center_coord(coord_));
    //sol_->reset_last_cell();
}

void rock::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
{
    emit dropped(this);
    QGraphicsItem::mouseReleaseEvent(event);
}

QVariant rock::itemChange(GraphicsItemChange change, const QVariant &value)
{
    if (change == ItemPositionChange)
    {
        emit position_changed(this, value.toPointF());
        //sol_->drag_rock(*this, value.toPointF());
    }
    return QGraphicsItem::itemChange(change, value);
}

void rock::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
    QGraphicsItem::mousePressEvent(event);
}

